
//
// 20120825 - AH - Created.
// 20120906 - AH - Missing java doc.
// 20121110 - AH - Moved from org.japril.jhut.framework.
// 20121113a- AH - Changed according to TestFactory.121113a.
// 20121113b- AH - Changed according to TestFactory.121113b.
//

package org.japril.jhut.framework.test;

import java.util.ArrayList;
import java.util.List;

import org.japril.jhut.framework.JhutTest;
import org.japril.jhut.framework.TestFactory;
import org.japril.jhut.swing.TestTreeManager;

/**
 * <p>
 *   {@link TestFactory} for testing the framework.
 * </p>
 * @author Arne Halvorsen (AH) 
 */
public final class SimulateForestFactory implements TestFactory 
{
  /**
   * <p>
   *   Constructor.
   * </p>
   */
  public SimulateForestFactory(){}
  
  // Specified in TestForestFactory.
  public String getName(){ return "Simulation"; }
  
  // Specified in TestForestFactory.
  public List<String> getWorldNames()
  {
    List<String> retVal=new ArrayList<String>();
    
    retVal.add("world 0");
    retVal.add("world 1");
    
    return retVal;
  }

  // Specified in TestForestFactory.
  public Object createWorld(String name)
  {
    if (name.equals("world 0")) return new TestWorld();
    if (name.equals("world 1")) return new TestWorld();
    return null;
  }

  // Specified in TestForestFactory.
  public List<JhutTest> createTests() 
  {
    List<JhutTest> retVal=new ArrayList<JhutTest>();
    
    SimulateJhutTest r0=new SimulateJhutTest();
    r0.setName("A test that goes ok");
    retVal.add(r0);
    
    SimulateJhutTest r0_1=new SimulateJhutTest();
    r0_1.setName("Another ok test");
    r0.addChild(r0_1);
    
    SimulateJhutTest r1=new SimulateJhutTest(true);
    r1.setName("A test that fails");
    retVal.add(r1);
    
    SimulateJhutTest r1_1=new SimulateJhutTest();
    r1_1.setName("A test not run since parent failed");
    r1.addChild(r1_1);
    
    return retVal;
  }
  
  public static void main(String[] args)
  {
    TestTreeManager.show(new SimulateForestFactory(), false, true); 
  }

}
